function handleTemplateStr(string) {
    // 处理模板字符串
    return string.replace(/\$\{(\w+)\}/g, function (matched, key){
        // console.log(matched,key) // ${name} name
        return eval(key)
    })
}

let name = 'sxt'
console.log(handleTemplateStr('i am ${name}'))